import 'package:encrypt/encrypt.dart' as encrypt;

const String keyValue = "comic_us_en_1234";

class AESUtil {
  /// AES加密 (ECB模式)
  static String encryptECB(String plainText) {
    final key = encrypt.Key.fromUtf8(keyValue);
    final encrypter = encrypt.Encrypter(
      encrypt.AES(key, mode: encrypt.AESMode.ecb),
    );
    final encrypted = encrypter.encrypt(plainText);
    return encrypted.base64;
  }

  /// AES解密 (ECB模式)
  static String decryptECB(String base64Str) {
    final key = encrypt.Key.fromUtf8(keyValue);
    final encrypter = encrypt.Encrypter(
      encrypt.AES(key, mode: encrypt.AESMode.ecb),
    );
    final decrypted = encrypter.decrypt64(base64Str);
    return decrypted;
  }
}
